﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using RenAi.Medical.BLL;
using RenAi.Medical.Model;

namespace RenAi.Medical.Admin
{
    public partial class UpdAnswer : System.Web.UI.Page
    {
        AnswerBLL bll = new AnswerBLL();
        ProblemBLL bll1 = new ProblemBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                LoadDoctor();
            }
        }
        public void LoadDoctor()
        {
            this.DropDownList1.DataSource = bll.ShowDoctor();
            this.DropDownList1.DataValueField = "Doctor_Id";
            this.DropDownList1.DataTextField = "Doctor_Name";
            this.DropDownList1.DataBind();
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {

            Answer a = new Answer();
            a.Acontent = this.txtcontent.Text;
            a.Adate = DateTime.Now;
            a.Pid =int.Parse(Request.QueryString["id"]);
            a.Doctor_Id = int.Parse(this.DropDownList1.SelectedValue);
            if(bll.AddAnswer(a)>0)
            {
                Problem p = new Problem();
                p.Pstate = "是";
                p.pid = int.Parse(Request.QueryString["id"]);
                bll1.UpdProblem(p);
                Response.Write("<script>alert('添加成功!')</script>");
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("wenti.aspx");
        }
    }
}